#pragma once
#include<iostream>
#include<assert.h>
using namespace std;
namespace lj
{
	template <class T>
	struct list_node
	{
		list_node<T>* _next;
		list_node<T>* _prev;
		T _val;
		list_node(const T& x)
			:_next(nullptr)
			, _prev(nullptr)
			, _val(x)
		{}
	};
	template<class T>
	struct _list_iterator
	{
		typedef list_node<T> node;
		node* _pnode;

		_list_iterator(node* p)
			:_pnode(p);
		{}

		T& operator*()
		{
			return _pnode->_val;
		}

		_list_iterator<T>& operator++()
		{
			_pnode = _pnode->_next;
			return *this;
		}
		_list_iterator<T> operator++(int)
		{
			_list_iterator<T> tmp(*this);
			_pnode = _pnode->_next;
			return tmp;
		}
		_list_iterator<T>& operator--()
		{
			_pnode = _pnode->_prev;
			return *this;
		}
		_list_ierator<T> operator--(int)
		{
			_list_iterator<T> tmp(*this);
			_pnode = _pnode->_prev;
			return tmp;
		}
		bool operator!=(const _list_iterator& it) const
		{
			return _pnode != it._pnode;
		}
		bool operator==(const _list_iterator& it) const
		{
			return _pnode == it._pnode;
		}
	};
	template <class T>
	class list
	{
		typedef list_node<T> node;
	public:
		typedef _list_iterator<T> iterator;
		//typedef _list_iterator<const T> const_iterator;
		void Buypnode()
		{
			_head = new node(T());
			_head->_next = _head;
			_head->_prev = _head;

			_size = 0;
		}
		list()
		{
			Buypnode();
		}
		/*list(const list<T>& lt)
		{
			Buypnode();
		}*/
		void push_back(const T& x)
		{
			node* newnode = new node(x);
			node* tail = _head->_prev;
			newnode->_next = _head;
			newnode->_prev = tail;
			tail->_next = newnode;
			_head->_prev = newnode;
		}
	private:
		node* _head;
		size_t _size;
	};
	void test_list1()
	{
		list<int> lt();
		list<int> lt1();
	}
}